package cn.javase.base.io._07_压缩和解压缩流;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

public class _02_解压缩流 {
    public static void main(String[] args) throws IOException {
        String path ="D:\\Code\\study\\JavaCode\\JavaSEDemo\\base\\src\\main\\java\\cn\\javase\\base\\io\\_07_压缩和解压缩流\\待压缩文本.txt.gz";
        GZIPInputStream gzipInputStream = new GZIPInputStream(new FileInputStream(path));
        FileOutputStream fileOutputStream = new FileOutputStream(path.replace("待压缩文本.txt.gz", "解压缩文本.txt"));
        byte[] buffer = new byte[1024];
        int len;
        while ((len = gzipInputStream.read(buffer)) != -1) {
            fileOutputStream.write(buffer, 0, len);
        }
        gzipInputStream.close();
        fileOutputStream.flush();
        fileOutputStream.close();
    }
}
